<template>
  <div>
    <city-header></city-header>
    <search-city :citys="cities"></search-city>
    <list-city
      :hotCity="hotCities"
      :citys="cities"
      :letter="letterText"
    ></list-city>
    <city-alphabet
      :cities="cities"
      @change="handLetterChange"
    ></city-alphabet>
  </div>
</template>
<script>
import axios from "axios";
import CityHeader from "./componets/Header";
import SearchCity from "./componets/Search";
import ListCity from "./componets/List";
import CityAlphabet from "./componets/Alphabet";
export default {
  name: "City",
  components: {
    CityHeader,
    SearchCity,
    ListCity,
    CityAlphabet
  },
  data() {
    return {
      cities: {},
      hotCities: [],
      letterText: ""
    };
  },
  methods: {
    getCityInfo() {
      axios.get("/api/city.json").then(this.getCitySucc);
    },
    getCitySucc(res) {
      res = res.data;
      if (res.ret && res.data) {
        this.hotCities = res.data.hotCities;
        this.cities = res.data.cities;
      }
    },
    handLetterChange(letter) {
      this.letterText = letter;
    }
  },
  mounted() {
    this.getCityInfo();
  }
};
</script>

<style lang="stylus" scoped>
</style>

